package com.flying.watch2;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;

import java.util.List;

public class PubClient2 {

    static String server = "/servers";

    public static void main(String[] args) throws Exception {
//        String hosts = "192.168.106.13:2181";
        String hosts = "127.0.0.1:2181";
        ZooKeeper zk = new ZooKeeper(hosts, 30000, null);
        zk.create(server + "/" + "server1", "aaadv".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
        zk.create(server + "/" + "server2", "aaadv".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);

//        List<String> subList = zk.getChildren(server, false);

//        byte[] bytes = zk.getData(server, false, null);
//        String str = new String(bytes);
//        System.out.println(str);
//        Thread.sleep(1000000);
        zk.close();
    }
}